package leetcode.editor.cn;

import java.math.BigInteger;

/**
题目名字---:字符串相加
题目编号---:415	
解题时间---:2021-09-25 20:38:46
*/

public class AddStrings{
    public static void main(String[] args) {
        Solution solution = new AddStrings().new Solution();    
    }
    
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public String addStrings(String num1, String num2) {
        //
        StringBuilder builder = new StringBuilder();
        int i=num1.length()-1;
        int j=num2.length()-1;
        //进位
        int k=0;
        while (i>=0||j>=0||k!=0) {
            int n1 = i>=0?num1.charAt(i)-'0':0;
            int n2 = j>=0?num2.charAt(j)-'0':0;
            int resNum = n1+n2+k;
            builder.append(resNum%10);
            k = resNum/10;
            i--;
            j--;
        }
        return new String(builder.reverse());
    }
}
//leetcode submit region end(Prohibit modification and deletion)


}